<?php
/**
 * 网页元素
 *
 * @version        $Id: ad_main.php 1 8:26 2010年7月12日Z tianya $
 * @package        DedeCMS.Administrator
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */

require_once(dirname(__FILE__).'/config.php');
require_once(DEDEINC.'/datalistcp.class.php');
require_once(DEDEINC.'/common.func.php');
setcookie('ENV_GOBACK_URL',$dedeNowurl,time()+3600,'/');
$ENV_GOBACK_URL = empty($_COOKIE['ENV_GOBACK_URL']) ? "join_main.php" : $_COOKIE['ENV_GOBACK_URL'];
if ($dopost == 'detail'){
	$join_id = empty($join_id) ? 0 : intval($join_id);
	$row = $dsql->GetOne("SELECT * FROM `#@__join` WHERE join_id='$join_id'");
	$row['sex'] = getsex($row['sex']);
	$row['isjoin'] = getisjion($row['isjoin']);
	include DedeInclude('templets/join_detail.htm');
	exit();
}elseif ($dopost == 'delete'){
    $dsql->ExecuteNoneQuery("DELETE FROM `#@__join` WHERE join_id='$join_id' ");
	 ShowMsg("成功删除一则加盟申请！", $ENV_GOBACK_URL);
	 exit();
}elseif ($dopost == 'audit'){
	global $dsql;
	$sql ="update #@__join set state=1 where join_id=".$join_id;
	$dsql->ExecuteNoneQuery($sql);
	
	ShowMsg("成功审核一则加盟申请！", $ENV_GOBACK_URL);
	exit();
}
$name = isset($name)? addslashes($name) : '';
$where_sql = ' 1 ';
if ($name){
	$where_sql .=" and name like '%".$name."%'";
}
if ($tel){
	$where_sql .= " and tel like '%".$tel."%'";
}
if ($isjoin){
	$where_sql .= " and isjoin like '%".$isjoin."%'";
}
if (is_numeric($state)){
	$where_sql .= " and state = ".$state;
}
$sql = "SELECT * FROM `#@__join` WHERE $where_sql ORDER BY join_id desc";
$dlist = new DataListCP();
$dlist->SetTemplet(DEDEADMIN."/templets/join_main.htm");
$dlist->SetSource($sql);
//print_r(getisjionoption());
$dlist->display();
function getstate($key){
	$state_arr = array(
	'1'=>'已审核',
	'0'=>'未审核');
	return $state_arr[$key];
}
//是否有意愿
function getisjion($key){
	$isjoin = array(
	'无'=>'无',
	'有'=>'有');
	if (!$key){
		return $isjoin;
		exit();
	}
	return $isjoin[$key];
}
function getisjionoption() {
		$position_option = '';
		$toarr = getisjion('');
		foreach ( $toarr as $key => $arr ) {
			$position_option .= "<option value='".$key."'>".$arr."</option>\n\r";
		}
		return  $position_option;
}
//姓别
function getsex($key){
	$isjoin = array(
	'1'=>'男',
	'2'=>'女');
	return $isjoin[$key];
}
//所在区域
function getinarea($key){
	$inarea = array(
	'步行街'=>'步行街',
	'商场'=>'商场',
	'社区'=>'社区');
	return $inarea[$key];
}
//资金来源
function formmoney($key){
	$formmoney = array(
	'自费'=>'自费',
	'贷款'=>'贷款');
	return $formmoney[$key];
}
//有无经验
function getjy($key){
	$jyarr = array(
	'有'=>'有',
	'无'=>'无');
	return $jyarr[$key];
}
//是否认同 
function getok($key){
	$okarr = array(
	'有'=>'有',
	'无'=>'无');
	return $okarr[$key];
}
//了解多久
function gethowold($key){
	$howoldarr = array(
	'一个月以下'=>'一个月以下',
	'2-6个月'=>'2-6个月',
	'半年以上'=>'半年以上');
	return $howoldarr[$key];
}
//了解多久
function getyouhope($key){
	$youhopearr = array(
	'资金'=>'资金',
	'技术'=>'技术',
	'供应产品'=>'供应产品');
	return $youhopearr[$key];
}
?>